#define  _CRT_SECURE_NO_WARNINGS

#include<iostream>
using namespace std;

class Person
{
public:
	Person(const char* name)
		:_name(name)
	{
		cout << "Person()" <<endl;
	}

	Person(const Person& p)
	{
		_name = p._name;
		cout << "Person(const Person& p)" << endl;
	}
	//p2 = p1 --> p2.operator=(p1)
	Person& operator=(const Person& p)
	{
		cout << "Person operator=(const Person& p)" << endl;
		if (this != &p)
		{
			_name = p._name;
		}
		return *this;
	}
	
	~Person()
	{
		cout << "~Person()" << endl;
	}
protected:
	string _name;
};
class Student : public Person
{
public:
	Student(const char* name,int num)
		: Person(name)
		,_num(num)
	{
	
	}
	Student(const Student& s)
		:Person(s),
		_num(s._num)
	{

	}
	Student& operator=(const Student& s)
	{
		if (this != &s)
		{
			Person::operator=(s);
			_num = s._num;
			return *this;
		}
	}
	~Student()
	{
		cout << "~Student()" << endl;
	}
protected:
	int _num;

};
int main()
{

	Person p("zhangsi");
	Student s1("zhangsan",10);
	Student s2("lisi",2);
	cout << sizeof(p) << endl;
	cout << sizeof(s1) << endl;


	//s2= s1;
}
